package com.useeinfo.oa.modules.inspection.entity;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.framework.sugar.tools.StringConverters;
import com.useeinfo.oa.modules.base.entity.Enterprise;

import javax.persistence.*;

/**
 * 维保模块设备和工艺的关联表
 */
@Entity
@Table(name = "facility_inspection")
public class FacilityInspection extends SuperClassEntity<FacilityInspection> {


    /**
     * 计划工单
     */
    @ManyToOne
    @JoinColumn(name = "planner_inspection_id")
    private PlannerInspection plannerInspection;

    public String getSerial() {
        return serial;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    /**
     * 工单流水号
     */
    private String serial;
    /**
     * 设备id
     */
    private Long facilityId;
    /**
     * 设备编号
     */
    private String facilityCode;

    /**
     * 设备名称
     */
    private String facilityName;
    /**
     * 设备区域id
     */
    private Long areaId;
    /**
     * 设备区域名称
     */
    private String areaName;
    /**
     * 类型
     */
    private Long facilityCatId;
    /**
     * 类型名称
     */
    private String facilityCatName;
    /**
     * 设备分组名称
     */
    private Long facilityGroupId;
    /**
     * 设备所属分组名称
     */
    private String facilityGroupName;
    /**
     * 设备分组编号
     */
    private String facilityGroupCode;
    /**
     * 二维码值
     */
    private String QRCode;

    /**
     * 工艺id
     */
    private Long inspectionId;

    /**
     * 工艺名称
     */

    private String inspectionName;
    /**
     * 规格型号
     */
    private String spec;
    /**
     * 维保内容快照
     */
    @Column(columnDefinition="text")
    private String inspectionDataContent;


    /**
     * 是否临时数据
     * @return
     */
    private boolean tempVal=true;
    /**
     * 所属企业
     */
    @ManyToOne
    @JoinColumn(name = "enterprise_id")
    private Enterprise enterprise;


    public Long getFacilityId() {
        return facilityId;
    }

    public void setFacilityId(Long facilityId) {
        this.facilityId = facilityId;
    }

    public String getFacilityCode() {
        return facilityCode;
    }

    public void setFacilityCode(String facilityCode) {
        this.facilityCode = facilityCode;
    }

    public String getFacilityName() {
        return facilityName;
    }

    public void setFacilityName(String facilityName) {
        this.facilityName = facilityName;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public Long getFacilityGroupId() {
        return facilityGroupId;
    }

    public void setFacilityGroupId(Long facilityGroupId) {
        this.facilityGroupId = facilityGroupId;
    }

    public String getFacilityGroupName() {
        return facilityGroupName;
    }

    public void setFacilityGroupName(String facilityGroupName) {
        this.facilityGroupName = facilityGroupName;
    }

    public String getFacilityGroupCode() {
        return facilityGroupCode;
    }

    public void setFacilityGroupCode(String facilityGroupCode) {
        this.facilityGroupCode = facilityGroupCode;
    }

    public Long getInspectionId() {
        return inspectionId;
    }

    public void setInspectionId(Long inspectionId) {
        this.inspectionId = inspectionId;
    }

    public String getInspectionName() {
        return inspectionName;
    }

    public void setInspectionName(String inspectionName) {
        this.inspectionName = inspectionName;
    }

    public Long getAreaId() {
        return areaId;
    }

    public void setAreaId(Long areaId) {
        this.areaId = areaId;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public Long getFacilityCatId() {
        return facilityCatId;
    }

    public void setFacilityCatId(Long facilityCatId) {
        this.facilityCatId = facilityCatId;
    }

    public String getFacilityCatName() {
        return facilityCatName;
    }

    public void setFacilityCatName(String facilityCatName) {
        this.facilityCatName = facilityCatName;
    }

    public String getQRCode() {
        return QRCode;
    }

    public void setQRCode(String QRCode) {
        this.QRCode = QRCode;
    }

    public Boolean getTempVal() {
        return tempVal;
    }

    public void setTempVal(Boolean tempVal) {
        this.tempVal = tempVal;
    }

    public PlannerInspection getPlannerInspection() {
        return plannerInspection;
    }

    public void setPlannerInspection(PlannerInspection plannerInspection) {
        this.plannerInspection = plannerInspection;
    }

    public boolean isTempVal() {
        return tempVal;
    }

    public void setTempVal(boolean tempVal) {
        this.tempVal = tempVal;
    }

    public String getInspectionDataContent() {
        return inspectionDataContent;
    }

    public void setInspectionDataContent(String inspectionDataContent) {
        this.inspectionDataContent = inspectionDataContent;
    }

    public Enterprise getEnterprise() {
        return enterprise;
    }

    public void setEnterprise(Enterprise enterprise) {
        this.enterprise = enterprise;
    }



    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = super.toJSONObject();
        jsonObject.put("facilityName", StringConverters.null2String(getFacilityName()));
        jsonObject.put("facilityCode", StringConverters.null2String(getFacilityCode()));
        jsonObject.put("facilityCatName", StringConverters.null2String(getFacilityCatName()));
        jsonObject.put("facilityCatId", StringConverters.null2String(getFacilityCatId()));
        jsonObject.put("facilityId", StringConverters.null2String(getFacilityId()));
        jsonObject.put("inspectionId", StringConverters.null2String(getInspectionId()));
        jsonObject.put("inspectionName", StringConverters.null2String(getInspectionName()));
        jsonObject.put("spec", StringConverters.null2String(getSpec()));
        jsonObject.put("serial", StringConverters.null2String(getSerial()));

        return jsonObject;
    }


}
